<%@ taglib prefix="s" uri="/struts-tags"%>

<s:set name="adminLoginCheck" value="%{#session.adminLogin}" />
<s:if test="%{#adminLoginCheck!=null}">
	<script>

	/* $(document).ready(function(){

	
	}); */
		$(document).ready(function(){
	/* 		$(function(){
			    //code
			
			  var aaa = document.getElementById("genderselected").value; //get option value from parent 
              
              switch(aaa){ //using switch compare selected option and populate child
                    case '1':
                      list(Woman);
                      break;
                    case '2':
                      list(Man);
                      break;              
                    case '3':
                      list(Kid);
                      break;  
                    case '4':
                        list(Neutral);
                        list2(Accessories);
                        break;                 
                  default: //default child option is blank
                      $("#categoryselected").html('');  
            	        $("#typeselected").html('');  
                      break;
                 } 
			}); */
				var Woman = [
 		        // 	{display: "--Please Select--", value: "" }, 
 	         	
		             {display: "T-Shirts/Tanks", value: "1" }, 
		             {display: "Sweaters", value: "3" }, 
		             {display: "Jackets", value: "4" },
		             {display: "Dresses", value: "5" },
		             {display: "Skirts", value: "6" },
		             {display: "Pants", value: "7" }, 
/* 		             {display: "Sweaters", value: "Sweaters" }, 
 */		             {display: "Shorts", value: "8" },
		             {display: "Leggins", value: "9" },
		             {display: "Others", value: "10" }
		             ];

		         var Man = [
		     //     	{display: "--Please Select--", value: "" },  
		             {display: "Shirts", value: "2" }, 
		             {display: "Sweaters", value: "3" }, 
		             {display: "Jackets", value: "4" },
		             {display: "Pants", value: "7" },
		             {display: "Shorts", value: "8" }, 
		             {display: "Others", value: "12" }, 
		             {display: "Tank Tops", value: "14" },
		             {display: "T-Shirts", value: "15" }
		             ];

		             
		         var Kid = [
		  //       	{display: "--Please Select--", value: "" }, 
		             {display: "Girls", value: "10" }, 
		             {display: "Boys", value: "11" }
		          ];

		         var TShirtsTanks =[
		               {display:"Sleeveless", value:"1"},
		               {display:"Crop Tops", value:"2"},
		               {display:"Short sleeve", value:"3"},
		               {display:"Long sleeve", value:"4"}
		                          ];

		         var Shirts =[
		                         {display:"Sleeveless", value:"1"},
		                         {display:"Crop Tops", value:"2"},
		                         {display:"Short sleeve", value:"3"},
		                         {display:"Long sleeve", value:"4"}
		                                                     ];

		         var Sweaters =[
		                      {display:"Pullovers", value:"5"},
		                      {display:"Cardigans", value:"6"},
		                      {display:"Sweaters", value:"7"}
		         ];

		         var Jackets =[
		                        {display:"Coats", value:"8"},
		                        {display:"Jackets", value:"9"}
		           ];

		         var Dresses_Skirts =[
		                       {display:"Mini", value:"10"},
		                       {display:"Mid-length", value:"11"},
		                       {display:"Long", value:"13"}
		          ];
		          
		         var Pants =[
		                       {display:"suit", value:"14"},
		                       {display:"Jeans", value:"15"},
		                       {display:"High waisted", value:"16"},
		                       {display:"Jumpsuits", value:"17"},
		                       {display:"Low rise", value:"18"},
		                       {display:"Chinos", value:"19"},
		                       {display:"Sweatpants", value:"20"}
		          ];
		          
		         var Girls =[
		                     {display:"Baby girls", value:"21"},
		                     {display:"Girls", value:"22"}
		         ];

		         var Boys =[
		                     {display:"Boys", value:"23"},
		                     {display:"Baby boys", value:"24"}
		         ];

		         var Others =[
		                     {display:"Nightwear", value:"25"},
		                     {display:"Sportswear", value:"26"},
		                     {display:"Swimwear", value:"27"},
		                     {display:"Underwear", value:"28"}
		         ];

		         var Accessories =[
		                     {display:"Headwear", value:"29"},
		                     {display:"Eyewear", value:"30"},
		                     {display:"Bags", value:"31"},
		                     {display:"Socks", value:"32"},
		                     {display:"Leather", value:"33"}
		         ];

		         var TShirts =[
		                           {display:"Short sleeve", value:"3"},
		                           {display:"Long sleeve", value:"4"}
		               ];


		         var Neutral = [
		                        {display:"Accessories", value:"13"}
		                ];
		        
		         //If Gender option is changed
		         $("#genderselected").change(function() {
		                 var parent = $(this).val(); //get option value from parent 
		                 
		                 switch(parent){ //using switch compare selected option and populate child
		                       case '1':
		                         list(Woman);
		                         break;
		                       case '2':
		                         list(Man);
		                         break;              
		                       case '3':
		                         list(Kid);
		                         break;  
		                       case '4':
		                           list(Neutral);
		                           list2(Accessories);
		                           break;                 
		                     default: //default child option is blank
		                         $("#categoryselected").html('');  
		               	        $("#typeselected").html('');  
		                         break;
		                    }
		         });
		        
				        
		        	
	                
	         
		        

		         //If Category option is changed
		         $("#categoryselected").change(function() {
		                 var parent = $(this).val(); //get option value from parent 
		                 
		                 switch(parent){ //using switch compare selected option and populate child
		                       case '1':
		                         list2(TShirtsTanks);
		                         break;
		                       case '2':
		                         list2(Shirts);
		                         break;              
		                       case '3':
		                         list2(Sweaters);
		                         break;  
		                       case '4':
		                           list2(Jackets);
		                           break;           
		                       case '5':
		                           list2(Dresses_Skirts);
		                           break;
		                         case '6':
		                           list2(Dresses_Skirts);
		                           break;              
		                         case '7':
		                           list2(pants);
		                           break;  
		                         case '10':
		                             list2(Girls);
		                             break;   
		                         case '11':
		                             list2(Boys);
		                             break;
		                           case '12':
		                             list2(Others);
		                             break;              
		                           case '13':
		                             list2(Accessories);
		                             break;  
		                           case '15':
		                               list2(TShirts);
		                               break;   
		                     default: //default child option is blank
		                         $("#typeselected").html('');  
		                         break;
		                    }
		         });

		         //function to populate child select box
		         function list(array_list)
		         {
		             $("#categoryselected").html(""); 
		             $(array_list).each(function (i) {
		                 $("#categoryselected").append("<option value=\""+array_list[i].value+"\">"+array_list[i].display+"</option>");
		                 
		             });
		             $("#typeselected")
		             .find("option")
		             .remove()
		             .end();
		         }

		         function list2(array_list2)
		         {
		         	
		             $("#typeselected").html(""); 
		             $(array_list2).each(function (i) {
		                 $("#typeselected").append("<option value=\""+array_list2[i].value+"\">"+array_list2[i].display+"</option>");
		             });
		         }

		         $(function(){
					    //code
					
					  var aaa = document.getElementById("genderselected").value; //get option value from parent 
		              
		              switch(aaa){ //using switch compare selected option and populate child
		                    case '1':
		                      list(Woman);
		                      break;
		                    case '2':
		                      list(Man);
		                      break;              
		                    case '3':
		                      list(Kid);
		                      break;  
		                    case '4':
		                        list(Neutral);
		                        list2(Accessories);
		                        break;                 
		                  default: //default child option is blank
		                      $("#categoryselected").html('');  
		            	        $("#typeselected").html('');  
		                      break;
		                 } 
		            //  document.getElementById("categoryselected").setAttribute(value, 1);
		            var bb =   1;
		            bb = document.getElementById("dsa").value; 
		            $('#categoryselected').val(bb);
		            
		            
		            var bbb = document.getElementById("categoryselected").value; 
		            //get option value from parent 
	                 
	                 switch(bbb){ //using switch compare selected option and populate child
	                       case '1':
	                         list2(TShirtsTanks);
	                         break;
	                       case '2':
	                         list2(Shirts);
	                         break;              
	                       case '3':
	                         list2(Sweaters);
	                         break;  
	                       case '4':
	                           list2(Jackets);
	                           break;           
	                       case '5':
	                           list2(Dresses_Skirts);
	                           break;
	                         case '6':
	                           list2(Dresses_Skirts);
	                           break;              
	                         case '7':
	                           list2(pants);
	                           break;  
	                         case '10':
	                             list2(Girls);
	                             break;   
	                         case '11':
	                             list2(Boys);
	                             break;
	                           case '12':
	                             list2(Others);
	                             break;              
	                           case '13':
	                             list2(Accessories);
	                             break;  
	                           case '15':
	                               list2(TShirts);
	                               break;   
	                     default: //default child option is blank
	                         $("#typeselected").html('');  
	                         break;
	                 }
		            
		            var cc = document.getElementById("dsd").value; 
		            		            $('#typeselected').val(bb);

					});
		         
		        //  alert("Text: " +  document.getElementById("dsa").value);

		         });
	
	
	</script>


	<s:form action="adminProductDetailEditSave" namespace="/">

		<s:iterator value="product_line">

			<s:textfield label="Name" key="name" />
			<br />

			<s:select label="Season" list="seasonList" listKey="id"
				listValue="name" value="season.getId()" name="yourSeason" />

			<s:select id="genderselected" label="Gender" list="genderList" listKey="id"
				listValue="name" value="gender.getId()" name="yourGender"
				 />


	<%-- 
		 	<s:select label="Category" list="categoryList" listKey="id"
				listValue="name" value="category.getId()" name="yourCategory" />


			<s:select label="Type" list="typeList" listKey="id" listValue="name"
				value="type.getId()" name="yourType" /> --%>
<s:set id = "setCategory" var="setCategory"  value="name" />
	<s:hidden id="dsa" name="url" value="%{category.getId()}" /> 
	<s:hidden id="dsd"  value="%{type.getId()}" /> 

<%--  <s:set var="personName" value="person.name"/>
 <s:set var="varMsg" value="name" /> --%>

 			<s:select label="Category" key="categoryselected" id="categoryselected" list="#{}" listKey="id" listValue="name" value="category.getId()" name="yourCategory"/>
			<s:select label="Type" key="typeselected" id="typeselected" list="#{}" listKey="id" listValue="name" value="type.getId()" name="yourType"/>
 

			<s:textfield type="number" label="Price" key="price" />
			<s:textfield disabled="true" label="Date" key="dateString" />

			<s:select label="Designer" list="designerList" listKey="id"
				listValue="name" value="designer.getId()" name="yourDesigner" />


			<s:div listenTopics="show_detail">
			</s:div>
<%-- Category: <s:property value="category.getName()" />

<br />Type: <s:property value="type.getName()" /> --%>
		</s:iterator>


		<s:hidden id="id" name="id" value="%{id}" />
		<s:submit name="saveChange" value="save">
		</s:submit>
	</s:form>

	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->
	<!-- 
	 -->

</s:if>

